package com.hp.config;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.hp.model.Admins;

public class AdminInterceptor extends HandlerInterceptorAdapter{

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {

		HttpSession session=request.getSession();
		Admins admin=(Admins) session.getAttribute("user");
		
		if(admin!=null) {
			//没有登录		
			return true;
		}else {
			//登录成功
			response.sendRedirect("login.jsp");
			
			return false;
		}
		
	}
	
	
}
